package com.tiancheng.trade.commom.core.data;

import java.util.LinkedList;
import java.util.List;

/**
 * 分页信息
 */
public class PageInfo<T> {
	private List<T> list;
	private Pagination pagination;

	public PageInfo(List<T> list, Pagination pagination) {
		this.list = list;
		this.pagination = pagination;
	}

	public List<T> getList() {
		if (this.list == null) {
			this.list = new LinkedList();
		}

		return this.list;
	}

	public Pagination getPagination() {
		return this.pagination;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public void setPagination(Pagination pagination) {
		this.pagination = pagination;
	}

	public PageInfo() {
	}

	public static class Pagination {
		private long currentPage;
		private int pageSize;
		private long total;
		private Long totalPage;

		public Pagination() {
			this.currentPage = 1L;
			this.pageSize = 0;
			this.total = 0L;
			this.totalPage = 0L;
		}

		public Pagination(long currentPage, int pageSize, long total) {
			this.currentPage = currentPage;
			this.pageSize = pageSize;
			this.total = total;
		}

		public long getTotalPage() {
			if (this.totalPage == null || this.totalPage == 0L) {
				this.totalPage = this.total / (long)this.pageSize;
				if (this.total % (long)this.pageSize != 0L) {
					Long var1 = this.totalPage;
					Long var2 = this.totalPage = this.totalPage + 1L;
				}
			}

			return this.totalPage;
		}

		public long getCurrentPage() {
			return this.currentPage;
		}

		public int getPageSize() {
			return this.pageSize;
		}

		public long getTotal() {
			return this.total;
		}

		public void setCurrentPage(long currentPage) {
			this.currentPage = currentPage;
		}

		public void setPageSize(int pageSize) {
			this.pageSize = pageSize;
		}

		public void setTotal(long total) {
			this.total = total;
		}

		public void setTotalPage(Long totalPage) {
			this.totalPage = totalPage;
		}
	}
}
